//
//  ViewController.m
//  LocalizableDemo
//
//  Created by 王郑 on 2018/8/11.
//  Copyright © 2018年 王郑. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor whiteColor];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:LK_GetStringWithKey(@"Please Choose Language") preferredStyle:(UIAlertControllerStyleActionSheet)];
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"简体中文" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        
        [[LKLanguageTool sharedInstance] setNewLanguage:(LKLanguageTypHans) completion:^(BOOL result) {
            if (result) {
                 [self restHomeVC];
            }
        }];
    }];
    
    UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"English" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        
        [[LKLanguageTool sharedInstance] setNewLanguage:(LKLanguageTypEn) completion:^(BOOL result) {
            
            if (result) {
                [self restHomeVC];
            }
            
        }];
    }];
    
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:LK_GetStringWithKey(@"Cancel") style:(UIAlertActionStyleCancel) handler:nil];
    [alert addAction:action];
    [alert addAction:action2];
    [alert addAction:cancel];
    [self presentViewController:alert animated:YES completion:nil];
}

- (void)restHomeVC{
    
    [UIApplication sharedApplication].keyWindow.rootViewController
    = [[HomeTabBarVC alloc] init];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
